<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.org/rich"
                template="/layout/template_box.xhtml"
                xmlns:a4j="http://richfaces.org/a4j">


  <ui:define name="head">
    <a4j:loadStyle src="/css/custom-theme/jquery-ui-1.8.2.custom.css"/>
    <!-- <a4j:loadScript src="/js/alertaInstituicao.js" />-->


  </ui:define>

  <ui:define name="MenuInterno">
    <ui:include src="/layout/menu_curso.xhtml"/>
  </ui:define>


  <ui:define name="body">

    <h2 class="t_curso">Cursos</h2>

    <div id="tamanho_div">


      <h:form styleClass="form_confea" ajaxSubmit="true">
      
	   	<fieldset>
			<h:messages globalOnly="true" styleClass="tool_alerta" />
		</fieldset>
      
      <fieldset>
            <legend>Opções de Busca</legend>
            <ol>
           
              <li>

                <s:div id="divNome">
	                <s:decorate id="nomeField" template="/layout/edit.xhtml">
	                  <ui:define name="label">Nome</ui:define>
	                  <h:inputText id="nome" styleClass="campo_full" required="true" requiredMessage="O campo é obrigatório" value="#{cursoList.cursoPesquisa.nome}" />
	                    
	                </s:decorate>
                </s:div>

              </li>

            </ol>
            <s:div id="divBotoes">
		        <h:commandLink styleClass="btn" valeu="Pesquisar" action="#{cursoList.pesquisar}">Pesquisar</h:commandLink>
		        <h:commandLink styleClass="btn" valeu="Limpar" immediate="true" action="#{cursoList.listar}" onclick="jQuery('[id$=nome]').val('')">Limpar</h:commandLink>
	        </s:div>
          </fieldset>
      
  
        <fieldset>
          <s:div rendered="#{listaCursos.size == 0}">
            <p class="tool_alerta"> Nenhum Curso encontrado.</p>
          </s:div>

          <rich:dataTable value="#{listaCursos}" var="_curso" styleClass="grid_dados" cellpadding="0" cellspacing="0"
          border="0"  id="cursoLista" rows="#{cursoList.paginacao}"
          rowClasses="grid_zebra,none">
        
            <rich:column >
              <f:facet name="header">Nome</f:facet>
              <h:outputText value="#{_curso.nome}"/>
            </rich:column>
            
            <rich:column  >
              <f:facet name="header" style="text-align:center" >Cadastros Reserva</f:facet>
              <a4j:commandLink title="Exibir cadastros reserva" immediate="true" style="text-align:center;text-decoration: underline;" rendered="#{_curso.cadastrosReserva.size()>0}" value="#{_curso.cadastrosReserva.size()}" >
              	<a4j:support event="onclick" reRender="panel" ajaxSingle="true" limitToList="true" eventsQueue="default" oncomplete="#{rich:component('panel')}.show()">
              		<f:setPropertyActionListener target="#{cursoList.curso}" value="#{_curso}" />
              	</a4j:support>
              </a4j:commandLink>
              
            </rich:column>


            <rich:column style="width:12%">
              <f:facet name="header">Ações</f:facet>
                <span>
                    <s:link title="Editar Curso"                 
                    id="btnEditar" styleClass="editar2" view="/curso/curso.xhtml" propagation="none">
	                   <f:param name="idCurso" value="#{_curso.id}"/>
                    </s:link>

		     		<h:commandLink title="Excluir" id="btnExcluir" rendered="#{s:hasRole('Gestor')}" immediate="true"
	                 	 	action="#{cursoList.apagar}"
	                    	styleClass="excluir2" 
	                    	onclick="return confirm('Confirmar exclusão?')">
	                </h:commandLink>

   	  			
   	  			</span>
            </rich:column>

          </rich:dataTable>
          <rich:datascroller id="scrolInstituicao"
            for="cursoLista" maxPages="#{cursoList.paginacao}"
            align="center" renderIfSinglePage="false"  />

        </fieldset>
      </h:form>
		<rich:modalPanel id="panel" width="550" autosized="true">
	        <f:facet name="header">
	            <h:panelGroup>
	                <h:outputText rendered="#{cursoList.curso!=null}" value="Lista de reservas do Curso - #{cursoList.curso.nome}"></h:outputText>
	            </h:panelGroup>
	        </f:facet>
	        <f:facet name="controls">
	            <h:panelGroup>
	                <h:graphicImage value="/imagens/close.png" styleClass="hidelink" id="hidelink"/>
	                <rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>
	            </h:panelGroup>
	        </f:facet>
	      
	         <div id="conteudo_pagina" style="background:none" >
       	<div id="tamanho_div" >
		   		<a4j:form id="formGeraDeclaracao" styleClass="form_confea">
					<a4j:outputPanel id="panelDeclaracaoForm" ajaxRendered="true">
						<fieldset>
				         
				         <li><s:decorate template="/layout/edit.xhtml"
									id="decoTurma">
									<ui:define name="label">
							Turma
						</ui:define>
									<h:selectOneMenu required="false" immediate="true"
										requiredMessage="O campo 'Turma' é obrigatório."
										id="turma" styleClass="Combo" 
										value="#{cursoList.turma}">
										<s:selectItems value="#{cursoList.curso.turmasAtivas}"
											var="turma" label="#{turma.nome}"
											noSelectionLabel="Selecione" />
										<s:convertEntity />
										<a4j:support event="onchange" reRender="turma" ajaxSingle="true"></a4j:support>							
									</h:selectOneMenu>

								</s:decorate></li>
				            
				            
				            <rich:dataTable value="#{cursoList.curso.cadastrosReserva}" var="_reserva" styleClass="grid_dados" cellpadding="0" cellspacing="0"
				          		border="0"  id="avaliacoesLista" rowKeyVar="indice"
				          			rowClasses="grid_zebra,none">
				        
					            <rich:column >
					              <f:facet name="header">Posição</f:facet>
					              <h:outputText value="#{indice+1}" >
					              </h:outputText>
					            </rich:column>
								<rich:column >
					              <f:facet name="header">Nome</f:facet>
					              <h:outputText value="#{_reserva.aluno.nome}" >
					              </h:outputText>
					            </rich:column>
		
								<rich:column>
									<f:facet name="header">Telefones</f:facet>
									<h:outputText value="#{_reserva.aluno.telefone} / #{_reserva.aluno.celular}" />
								</rich:column>
								
								<rich:column >
					              <f:facet name="header">Ações</f:facet>
					                <span>
					                   				
							     		<h:commandLink title="Incluir" id="btnExcluir" immediate="true"
						                 	 	action="#{cursoList.adicionarNaTurma()}"
						                    	styleClass="adicionar" 
						                    	>
						                    	<f:setPropertyActionListener target="#{cursoList.cadastroReserva}" value="#{_reserva}" />
						                </h:commandLink>
					
					   	  			
					   	  			</span>
					            </rich:column>
								
				          </rich:dataTable>
				            
				            
		            	</fieldset>
	         
					</a4j:outputPanel>
					</a4j:form>
					</div>
					</div>
					
	    </rich:modalPanel>	
    </div>
  </ui:define>

</ui:composition>
